/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package py.fpuna.ii.electiva2.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author Lauri
 */
@Entity
@Table(name = "compra")
@NamedQueries({@NamedQuery(name = "Compra.findAll", query = "SELECT c FROM Compra c"), @NamedQuery(name = "Compra.findByCompCantidad", query = "SELECT c FROM Compra c WHERE c.compCantidad = :compCantidad"), @NamedQuery(name = "Compra.findByCompProveedor", query = "SELECT c FROM Compra c WHERE c.compProveedor = :compProveedor"), @NamedQuery(name = "Compra.findByCompCodigo", query = "SELECT c FROM Compra c WHERE c.compCodigo = :compCodigo")})
public class Compra implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "comp_cantidad")
    private Integer compCantidad;
    @Column(name = "comp_proveedor")
    private Integer compProveedor;
    @Id

    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="compra_seq_generator")
    @SequenceGenerator(name="compra_seq_generator", sequenceName="compra_comp_codigo_seq",allocationSize=1)

    @Basic(optional = false)
    @Column(name = "comp_codigo")
    private Integer compCodigo;
    @JoinColumn(name = "comp_producto", referencedColumnName = "prod_codigo")
    @ManyToOne
    private Producto compProducto;

    public Compra() {
    }

    public Compra(Integer compCodigo) {
        this.compCodigo = compCodigo;
    }

    public Integer getCompCantidad() {
        return compCantidad;
    }

    public void setCompCantidad(Integer compCantidad) {
        this.compCantidad = compCantidad;
    }

    public Integer getCompProveedor() {
        return compProveedor;
    }

    public void setCompProveedor(Integer compProveedor) {
        this.compProveedor = compProveedor;
    }

    public Integer getCompCodigo() {
        return compCodigo;
    }

    public void setCompCodigo(Integer compCodigo) {
        this.compCodigo = compCodigo;
    }

    public Producto getCompProducto() {
        return compProducto;
    }

    public void setCompProducto(Producto compProducto) {
        this.compProducto = compProducto;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (compCodigo != null ? compCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Compra)) {
            return false;
        }
        Compra other = (Compra) object;
        if ((this.compCodigo == null && other.compCodigo != null) || (this.compCodigo != null && !this.compCodigo.equals(other.compCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.fpuna.ii.electiva2.entity.Compra[compCodigo=" + compCodigo + "]";
    }

}
